/****

    activequant - activestocks.eu

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

	
	contact  : contact@activestocks.eu
    homepage : http://www.activestocks.eu

****/
package org.activequant.util.exceptions;

/**
 * An Exception subclass. Holds the following associated variables:
 * <ul>
 * <li>msg(String)</li>
 * <li>reason(Reason)</li>
 * </ul>
 * <br>
 * <b>History:</b><br>
 *  - [31.05.2006] Created (Erik Nijkamp)<br>
 *
 *  @author Erik Nijkamp
 */
public class ConnectionException extends Exception {
    
	private static final long serialVersionUID = -4657085958058260606L;
	/**
	 * An enum with values: NOT_LOGGED_IN, WRONG_USERNAME_PWD, HOST_UNAVAILABLE, PROTOCOL_ERROR, UNKNOWN
	 * @author Dimitar
	 *
	 */
	public enum Reason {
        NOT_LOGGED_IN,
        WRONG_USERNAME_PWD,
        HOST_UNAVAILABLE,
        PROTOCOL_ERROR,
        UNKNOWN
    }
    /**
     * private String msg = "";
     */
    private String msg = "";
    /**
     * private Reason reason = Reason.UNKNOWN;
     */
    private Reason reason = Reason.UNKNOWN;
    /**
     * constructs a ConnectionException(Exception subclass) using the given reason(Reason) and msg(String) to
     * set its associated reason(Reason) and msg(String)
     * @param reason
     * @param msg
     */
    public ConnectionException(Reason reason, String msg) {
        this.reason = reason;
        this.msg = msg;
    }
    /**
     * returns a String in the form: "Reason: ${reason} ${msg}"
     */
    public String getMessage() {
        return "Reason: " + reason + " " + msg;
    }
    /**
     * returns the associated reason(Reason)
     * @return
     */
    public Reason getReason() {
        return reason;
    }
}
